﻿using Server.DTool;
using Server.Struct;
using System;
using System.Collections.Generic;
using System.Net.Sockets;

namespace Server.Net
{
    class NetEventArgs : IPoolItem, IBufferSegment
    {
        //static readonly byte[] EmptyBuffer = new byte[1] { 0 };
        public int ItemId { get; set; }
        public int Index { get; set; }

        public SocketAsyncEventArgs SendArgs { get; set; }
        public SocketAsyncEventArgs RecvArgs { get; set; }

        public UserToken Token { get; set; }

        public int Offset { get; private set; }

        public int Count { get; private set; }

        public void SetBuffer(byte[] buffer, int offset, int count)
        {
            Offset = offset;
            Count = count;
            int len = count / 2;
            SendArgs.SetBuffer(buffer, offset, len);
            RecvArgs.SetBuffer(buffer, offset + len, count - len);
        }
    }
}
